package com.gbiac.modules.monitor.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.gbiac.modules.monitor.param.ForceCheckOutAllParam;
import com.gbiac.modules.monitor.param.ForceCheckOutParam;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import com.gbiac.modules.monitor.entity.SeatUser;
import com.gbiac.modules.monitor.service.ISeatUserService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;

 /**
 * @Description: 席位当前用户
 * @Author: jeecg-boot
 * @Date:   2024-11-30
 * @Version: V1.0
 */
@Api(tags="席位当前用户")
@RestController
@RequestMapping("/monitor/seatUser")
@Slf4j
public class SeatUserController extends JeecgController<SeatUser, ISeatUserService> {
	@Autowired
	private ISeatUserService seatUserService;
	
	/**
	 * 分页列表查询
	 *
	 * @param seatUser
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "席位当前用户-分页列表查询")
	@ApiOperation(value="席位当前用户-分页列表查询", notes="席位当前用户-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<SeatUser>> queryPageList(SeatUser seatUser,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<SeatUser> queryWrapper = QueryGenerator.initQueryWrapper(seatUser, req.getParameterMap());
		Page<SeatUser> page = new Page<SeatUser>(pageNo, pageSize);
		IPage<SeatUser> pageList = seatUserService.page(page, queryWrapper);
		return Result.OK(pageList);
	}


	@AutoLog(value = "席位当前用户-强制离线席位")
	@ApiOperation(value="席位当前用户-强制离线席位", notes="席位当前用户-强制离线席位")
	@PostMapping(value = "/forceCheckOut")
	public Result<?> forceCheckOut(@Valid @RequestBody ForceCheckOutParam param) {
		seatUserService.forceCheckOut(param);
		return Result.ok("操作成功");
	}

	 @AutoLog(value = "席位当前用户-强制离线所有席位")
	 @ApiOperation(value="席位当前用户-强制离线所有席位", notes="席位当前用户-强制离线所有席位")
	 @PostMapping(value = "/forceCheckOutAll")
	 public Result<?> forceCheckOutAll(@Valid @RequestBody ForceCheckOutAllParam param) {
		 seatUserService.forceCheckOutAll(param);
		 return Result.ok("操作成功");
	 }
}
